#pragma once
#include "../core/graphic/texture.h"
#include "../core/graphic/render_item.h"

#include <ft2build.h>
#include FT_FREETYPE_H

#include <freetype/freetype.h>
#include <freetype/ftglyph.h>
#include <freetype/ftoutln.h>
#include <freetype/fttrigon.h>

class KFontManager
{
public:
	KFontManager();
	~KFontManager();

	static KFontManager* GetInstance();

	int LoadAnsiCharFromFont(const char* fontFileName, int height);

	bool Initialize();
	void Destory();

	void TextOut(const char* pStr, const KDrawLocal& local, int fontID = -1) const;

private:
	FT_Library  mFTLibrary;
	int mDefaultFontIndex;
	KRenderState mFontRS;

	struct CHAR_OFFSET
	{
		KSpriteRect tex_rect;
		int offset_dx;
		int offset_dy;
	};
	struct ANSI_CHAR_DESC 
	{
		KTexture* texture[2];
		bool second_tex[128];
		CHAR_OFFSET char_offset[128];
	};

	std::vector<ANSI_CHAR_DESC*> mAnsiCharData;
};

